package net.alpenviewer.map;

import org.geotools.measure.Latitude;
import org.geotools.measure.Longitude;
import org.geotools.measure.Measure;
import org.geotools.referencing.crs.DefaultGeographicCRS;


/**
 * An Latitude/Longitude point.
 */
public final class LatLong {
	
	private static DefaultGeographicCRS crsWGS84 = DefaultGeographicCRS.WGS84;
	
	public final Latitude  latitude;  /*NS*/
	public final Longitude longitude; /*EW*/
	
	public LatLong(Latitude lat, Longitude lon) {
		this.latitude = lat;
		this.longitude = lon;
	}

	@Override public String toString() {
		return "(" + this.latitude + " " + this.longitude + ")";
	}
	
	/**
	 * @return distance.
	 */
	public Measure distanceTo(LatLong latLong) {
		return crsWGS84.distance(
				new double[]{ latLong.longitude.degrees(), latLong.latitude.degrees() },
				new double[]{ this.longitude.degrees(), this.latitude.degrees() });		
	}

}
